lib/repo-pull: Factor out enqueue function for FetchStaticDeltaData
authorPhilip Withnall <withnall@endlessm.com>
Tue, 22 May 2018 11:20:15 +0000 (12:20 +0100)
committerAtomic Bot <atomic-devel@projectatomic.io>
Fri, 25 May 2018 13:12:33 +0000 (13:12 +0000)
This introduces no functional changes, but will make upcoming support
for retrying downloads easier to add.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #1599
Approved by: jlebon

src/libostree/ostree-repo-pull.c

index b9cafa9da8145065915edc67b8f3a4a3a255c6c3..f05f88359c247737876260009462bfe32e641c61 100644 (file)
@@ -226,6 +226,8 @@ static void queue_scan_one_metadata_object_c (OtPullData                *pull_da
 
 static void enqueue_one_object_request_s (OtPullData      *pull_data,
                                           FetchObjectData *fetch_data);
+static void enqueue_one_static_delta_part_request_s (OtPullData           *pull_data,
+                                                     FetchStaticDeltaData *fetch_data);
 
 static gboolean scan_one_metadata_object (OtPullData                 *pull_data,
                                           const char                 *checksum,
@@ -2131,6 +2133,24 @@ process_one_static_delta_fallback (OtPullData   *pull_data,
   return TRUE;
 }
 
+static void
+enqueue_one_static_delta_part_request_s (OtPullData           *pull_data,
+                                         FetchStaticDeltaData *fetch_data)
+{
+  if (fetcher_queue_is_full (pull_data))
+    {
+      g_debug ("queuing fetch of static delta %s-%s part %u",
+               fetch_data->from_revision ?: "empty",
+               fetch_data->to_revision, fetch_data->i);
+
+      g_hash_table_add (pull_data->pending_fetch_deltaparts, fetch_data);
+    }
+  else
+    {
+      start_fetch_deltapart (pull_data, fetch_data);
+    }
+}
+
 static void
 start_fetch_deltapart (OtPullData *pull_data,
                        FetchStaticDeltaData *fetch)
@@ -2313,12 +2333,7 @@ process_one_static_delta (OtPullData                 *pull_data,
         }
       else
         {
-          if (!fetcher_queue_is_full (pull_data))
-            start_fetch_deltapart (pull_data, fetch_data);
-          else
-            {
-              g_hash_table_add (pull_data->pending_fetch_deltaparts, fetch_data);
-            }
+          enqueue_one_static_delta_part_request_s (pull_data, g_steal_pointer (&fetch_data));
         }
     }